<!--
 * @Description: 
 * @Author: charles
 * @Date: 2021-07-13 09:20:15
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-08-03 16:53:11
-->
<template>
  <div class="header">
      <!-- +wrapper的原因：容器居中显示 -->
        <!-- 第一行 -->
      <div class="header_top">
        <div class="wrapper">
        <div class="left">山西农业大学欢迎您！</div>
        <div class="right">学校主页</div>
        </div>
      </div>
      <!-- 第二行 -->
      <div class="header_main">
        <div class="wrapper">
        <div class="logo">
          <img src="/resources/images/logo.png" alt="">
          </div>
          <ul class="menu">
            <li v-for="c in categories" 
            :key="c.id">
              {{c.name}}</li>
          </ul>
        </div>
      </div>
    </div>
</template>
<script>
import { get } from '../../utils/request'
export default{
  data(){
    return{
      categories:[]
    }
  }, 
  methods:{
    //跳转
    
    //加载栏目信息
    loadCategories(){
      let url='/index/category/findAll'
      get(url).then(resp =>{
        this.categories=resp.data;
      })
    }
  },
  created(){
    this.loadCategories();
  }
}
</script>
<style lang="scss" scoped>
$color_primary:#028b39;
.header{
  .header_top{
    background-color: $color_primary;
    color: #fff;
    // 加入伪元素来支撑父元素的高度
    & > .wrapper::after{
      display: block;
      content: '';
      clear: both;
    }
    .left,.right{
      line-height: 3em;
    }
    .left{
      float: left;
    }
    .right{
      float:right;
    }
  }
  .header_main{
    padding: .5em 0;
    & > .wrapper{
      display: flex;                  //伸缩盒
      justify-content: space-between; //空白在中间  space-around：左中右都有空白
      position: relative;
    }
    .logo{
      img{
        height: 50px;
      }
    }
    ul.menu{
      position:absolute;
      bottom: 0;
      right: 0;
      & > li{
        float: left;
        padding: 0.5em;
        cursor: pointer;
      }
      & > li.current ,
      & {
          background-color: $color_primary;
          color:#fff;
      }
    }
  }
}
</style>